package com.wang.springbootinit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.springbootinit.mapper.ResearchChapterMapper;
import com.wang.springbootinit.model.entity.ResearchChapter;
import com.wang.springbootinit.service.ResearchChapterService;
import com.wang.springbootinit.service.ResearchSubjectService;
import com.wang.springbootinit.service.ResearchUniversityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service
public class ResearchChapterServiceImpl extends ServiceImpl<ResearchChapterMapper, ResearchChapter>
    implements ResearchChapterService {

    @Autowired
    private ResearchChapterService researchChapterService; //章节

    @Autowired
    private ResearchSubjectService researchSubjectService; //科目

    @Autowired
    private ResearchUniversityService researchUniversityService; //大学

    @Override
    public List<ResearchChapter> listBySubjectId(long subjectId) {
        return this.lambdaQuery()
                .eq(ResearchChapter::getSubjectId, subjectId)
                .orderByAsc(ResearchChapter::getSortOrder)
                .list();
    }

    @Override
    public List<ResearchChapter> getChapterBySubjectId(long id) {
        return this.lambdaQuery()
                .eq(ResearchChapter::getSubjectId, id)
                .orderByAsc(ResearchChapter::getSortOrder)
                .list();
    }
} 